package org.rency.ues.engine.validator;

import org.rency.ues.common.UesDict;
import org.rency.ues.common.enums.EncryptType;
import org.rency.ues.domain.request.EncryptRequest;
import org.rency.ues.domain.response.EncryptResponse;
import org.springframework.util.Assert;

/**
 * $TODO
 *
 * @author: Created by user_rcy@163.com on 2016/08/02.
 * @version: V1.0.0
 * @since JDK 1.8
 */
public class EncryptValidator extends AbstractRequestValidator<EncryptRequest, EncryptResponse>{

    @Override
    protected void validate(EncryptRequest encryptRequest) {
        Assert.isTrue(EncryptType.RSA == encryptRequest.getEncryptType(),String.format(UesDict.CHINESE_NOT_SUPPORT_ENCRYPT_TYPE_MSG,encryptRequest.getEncryptType().getCode()));
    }

    @Override
    protected String getValidatorName() {
        return "加密";
    }

    @Override
    protected EncryptResponse success() {
        return EncryptResponse.success();
    }

    @Override
    protected EncryptResponse fail(String returnMessage) {
        return EncryptResponse.fail(returnMessage);
    }
}
